{layout name="merchant/layout_iframe" /}
<blockquote class="layui-elem-quote">分配会话原则: 在线状态 > 优先级 > 会话数量</blockquote>
<table id="dataTable" lay-filter="dataTable"></table>
<script type="text/html" id="toolbar">
  <div class="layui-btn-group fl">
      <a href="{:url('addUser')}" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-add-circle-fine" title="添加管理员">&nbsp;添加</a>
      <!-- <a data-href="{:url('status?val=1')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns layui-icon layui-icon-play" data-table="dataTable">&nbsp;启用</a>
      <a data-href="{:url('status?val=0')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns layui-icon layui-icon-pause" data-table="dataTable">&nbsp;禁用</a> -->
      <!-- <a data-href="{:url('delUser')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon layui-icon-close red">&nbsp;删除</a> -->
  </div>
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
    <a href="{:url('editUser')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal " title="修改">修改</a>
    <span data-href="{:url('resetUser')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-warm j-ajax" confirm="重置密码为:{$password}" title="重置密码">重置密码</span>
    <span data-href="{:url('delUser')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-primary j-tr-del">删除</span>
</script>
{include file="merchant/layout_layui" /}
<script>
    layui.use('table', function () {
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#dataTable'
            , url: '{:url('index')}' //数据接口
        , page: true //开启分页
            , toolbar: '#toolbar'
            , cols: [[ //表头
                {type: 'numbers'}
                , {field: 'experience', title: '操作',width:180,align:'center',templet:'#buttonTpl'}
                , {field: 'code', title: '头像', width: 70, templet: function (t) {
                    return '<img width=50 hegiht=50 src="' + t.avatar + '"  onerror="nopic();">';
                  }}
                , {field: 'code', title: '当前会话', width: 100,align:'center', templet: function (t) {
                    return '<span style="font-size:28px">'+t.service_num+'</span>';
                  }}
                  , {field: 'code', title: '优先级别', width: 100,align:'center', templet: function (t) {
                    return '<span style="font-size:28px">'+t.sort+'</span>';
                  }}
                , {field: 'username', title: '客服信息',templet:function(t){
                    let online = t.online==1 ? '是' : '否';
                    let color = t.online==1 ? '#009900' : '#FF5722';
                    return '<span style="color:'+color+'">昵称:'+t.username+'<br>在线:'+ online+'</span>';
                }}
                , {field: 'sex', title: '登录信息',templet:function(t){
                    let last_login_time = t.last_login_time == null ? '无' : t.last_login_time ;
                    return '最后登录:'+last_login_time+'<br>登录次数:'+t.login_count;
                }}

            ]]
        });

    });
</script>